def ivb(s):
    stack = []
    ob = "([{<"
    cb = ")]}>"
    for bracket in s:
        if bracket in ob:
            stack.append(bracket)
        elif bracket in cb:
            if len(stack) == 0:
                return False
            last_opening_bracket = stack.pop()
            if ob.index(last_opening_bracket) != cb.index(bracket):
                return False
    if len(stack) > 0:
        return False
    return True

sequences = input().split()
for sequence in sequences:
    if ivb(sequence):
        print(sequence + " - true")
    else:
        print(sequence + " - false")
